package com.ai.bitcoin.weixin.template;

import com.ai.bitcoin.util.DateUtil;
import com.google.common.collect.Maps;
import org.apache.commons.lang3.StringUtils;

import java.util.Map;

public class MonitorReportTemplate extends BaseTemplate {

    private final String templateId = "0MulMaxEFyOyY89slxKh7qrfeNDQeknVPHQfrJDpJ4Q";

    /**
     *
     {{first.DATA}}
     监控对象：{{keyword1.DATA}}
     监控项目：{{keyword2.DATA}}
     监控时段：{{keyword3.DATA}}
     {{remark.DATA}}
     * @param request
     * @return
     */
    @Override
    public Map<String, Object> buildParameterMap(Map<String, Object> request) {
        Map<String,Object> resp = Maps.newHashMap();
        resp.put("touser", request.get("touser"));
        resp.put("template_id", templateId);
        resp.put("url", request.get("url"));
        Map<String,Object> dataMap = Maps.newHashMap();
        dataMap.put("first", buildDataMap(String.valueOf(request.get("first"))));
        dataMap.put("keyword1", buildDataMap(String.valueOf(request.get("keyword1"))));
        dataMap.put("keyword2", buildDataMap(String.valueOf(request.get("keyword2"))));
        dataMap.put("keyword3", buildDataMap(DateUtil.currentDate2Str("yyyy-MM-dd HH:mm:ss")));
        if(request.get("remark") != null && !StringUtils.isEmpty(String.valueOf(request.get("remark")))) {
            dataMap.put("remark", buildDataMap(String.valueOf(request.get("remark"))));
        }
        resp.put("data", dataMap);
        return resp;
    }
}
